// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Serverless.Fluent;
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement;

public sealed partial class IndexSettingBlocks
{
	[JsonInclude, JsonPropertyName("metadata")]
	public bool? Metadata { get; set; }
	[JsonInclude, JsonPropertyName("read")]
	public bool? Read { get; set; }
	[JsonInclude, JsonPropertyName("read_only")]
	public bool? ReadOnly { get; set; }
	[JsonInclude, JsonPropertyName("read_only_allow_delete")]
	public bool? ReadOnlyAllowDelete { get; set; }
	[JsonInclude, JsonPropertyName("write")]
	public bool? Write { get; set; }
}

public sealed partial class IndexSettingBlocksDescriptor : SerializableDescriptor<IndexSettingBlocksDescriptor>
{
	internal IndexSettingBlocksDescriptor(Action<IndexSettingBlocksDescriptor> configure) => configure.Invoke(this);

	public IndexSettingBlocksDescriptor() : base()
	{
	}

	private bool? MetadataValue { get; set; }
	private bool? ReadValue { get; set; }
	private bool? ReadOnlyValue { get; set; }
	private bool? ReadOnlyAllowDeleteValue { get; set; }
	private bool? WriteValue { get; set; }

	public IndexSettingBlocksDescriptor Metadata(bool? metadata = true)
	{
		MetadataValue = metadata;
		return Self;
	}

	public IndexSettingBlocksDescriptor Read(bool? read = true)
	{
		ReadValue = read;
		return Self;
	}

	public IndexSettingBlocksDescriptor ReadOnly(bool? readOnly = true)
	{
		ReadOnlyValue = readOnly;
		return Self;
	}

	public IndexSettingBlocksDescriptor ReadOnlyAllowDelete(bool? readOnlyAllowDelete = true)
	{
		ReadOnlyAllowDeleteValue = readOnlyAllowDelete;
		return Self;
	}

	public IndexSettingBlocksDescriptor Write(bool? write = true)
	{
		WriteValue = write;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (MetadataValue.HasValue)
		{
			writer.WritePropertyName("metadata");
			writer.WriteBooleanValue(MetadataValue.Value);
		}

		if (ReadValue.HasValue)
		{
			writer.WritePropertyName("read");
			writer.WriteBooleanValue(ReadValue.Value);
		}

		if (ReadOnlyValue.HasValue)
		{
			writer.WritePropertyName("read_only");
			writer.WriteBooleanValue(ReadOnlyValue.Value);
		}

		if (ReadOnlyAllowDeleteValue.HasValue)
		{
			writer.WritePropertyName("read_only_allow_delete");
			writer.WriteBooleanValue(ReadOnlyAllowDeleteValue.Value);
		}

		if (WriteValue.HasValue)
		{
			writer.WritePropertyName("write");
			writer.WriteBooleanValue(WriteValue.Value);
		}

		writer.WriteEndObject();
	}
}